package net.hiapoe.gsnake4j.window;

import java.awt.Toolkit;

import javax.swing.JFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

import net.hiapoe.gsnake4j.listener.MainWinListener;
/**
 * 
 * @Author Administrator
 * @Description 主窗口
 * @Version 1.0.3 
 * @Date 2013年10月1日
 */
public class MainWin extends JFrame {
	private static final long serialVersionUID = 1L;
	private JMenuBar jmb = new JMenuBar();

	public MainWin() {
		this.setIconImage(Toolkit.getDefaultToolkit().getImage(
				"./img/MainWinIcon.png"));
		this.setDefaultCloseOperation(EXIT_ON_CLOSE);
		this.setVisible(true);
		this.setSize(445, 397);
		this.setLocationRelativeTo(null);
		this.setResizable(false);
		this.setTitle(RunMe.VERSION);
		this.addKeyListener(MainWinListener.getInstance(this));
		// this.addKeyListener(new MainWinListener(this));
		this.setJMenuBar(jmb);
		String[] menulab = { "选项", "设置", "帮助" };
		String[][] menuItemLab = { { "重新开始", "退出" },{"实时响应","周期响应"}, { "最高得分", "操作方法", "关于" } };
		for (int i = 0; i < menulab.length; i++) {
			JMenu menu = new JMenu(menulab[i]);
			jmb.add(menu);
			for (int j = 0; j < menuItemLab[i].length; j++) {
				JMenuItem jmi = new JMenuItem(menuItemLab[i][j]);
				menu.add(jmi);
				jmi.addActionListener(MainWinListener.getInstance(this));
				// jmi.addActionListener(new MainWinListener(this));
			}
		}
	}
}
